package cn.edu.buaa.cnsatm.traffic_big_data_server.highway.service;

import cn.edu.buaa.cnsatm.traffic_big_data_server.highway.dao.HighwayCongestionDAO;
import cn.edu.buaa.cnsatm.traffic_big_data_server.highway.model.HighwayCongestPointModel;
import cn.edu.buaa.cnsatm.traffic_big_data_server.highway.model.HighwayCongestionModel;
import cn.edu.buaa.cnsatm.traffic_big_data_server.util.*;
import cn.edu.buaa.cnsatm.traffic_big_data_server.waterway.dao.SeaStatusDAO;
import cn.edu.buaa.cnsatm.traffic_big_data_server.waterway.model.BoatModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.activemq.artemis.api.core.Pair;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.TreeMap;

/**
 * @name = LX
 * @classname = HighwayCongestionService
 * @description =
 * @date = 2019/10/18
 */
public class HighwayCongestionService {
    public static void main(String args[]) throws ParseException, SQLException, IOException, InterruptedException {
        JDBCUtil.startConnection();
        //System.out.println(tempCongestionPoint());
        //getMainHighwayLocation();
        //updateHighwayCongestionMap();
        //getHighwayCongestionFromWebSaveToDatabase();
        //System.out.println(getTopKCongestHighwayFromDatabase(5));
    }
    public static String getTopKCongestHighwayFromDatabase(Integer k) throws SQLException {
        /**
         * @author: LX
         * @methodName: getTopKCongestHighwayFromDatabase
         * @description: 从数据库中获取离现在时间最近的，拥挤度index排名前k的公路信息（路名，路描述，时间，拥挤度）
         * @data: 2019-10-19
         **/
        ResultSet resultSet = HighwayCongestionDAO.getTopKCongestHighwayFromDatabase(k);
        JsonArray ja = new JsonArray();
        while (resultSet.next()){
            JsonObject jo = new JsonObject();
            String x = new DecimalFormat("#.00").format(Math.atan(resultSet.getDouble("index")) * 2 / Math.PI * 100);
            jo.addProperty("highway_name",  resultSet.getString("road_name")+ " " + resultSet.getString("description"));
//            jo.addProperty("congestion", resultSet.getDouble("index"));
            jo.addProperty("congestion", x);
            jo.addProperty("datetime", resultSet.getString("update_time"));
//            jo.addProperty("longitude", resultSet.getDouble("longitude"));
//            jo.addProperty("latitude", resultSet.getDouble("latitude"));
            jo.add("geometry",(JsonObject) JsonParser.parseString(JsonArrayToGeoJsonUtil.wkbToJson(resultSet.getString("geom"))));
            ja.add(jo);
        }
        resultSet.getStatement().close();
        resultSet.close();
        return ja.toString();
    }
    public static String getCityHighwayURL(String cityCode){
        /**
         * @name = LX
         * @methodname = getCityHighwayURL
         * @description = 拼接百度地图特定城市公路拥挤度的URL
         * @date = 2019/10/19
         */
        final String s1 = " https://jiaotong.baidu.com/trafficindex/city/roadrank?cityCode=";
        final String s2 = "&roadtype=0&callback=jsonp_1571466707073_9532519";//注意改回0
        return s1 + cityCode + s2;
        //https://jiaotong.baidu.com/trafficindex/city/roadcurve?cityCode=131&id=%E4%BA%AC%E8%97%8F%E9%AB%98%E9%80%9F-3
    }
    public static void getMainHighwayLocation() throws SQLException, InterruptedException, IOException {
        List<Pair<String, String>> cityCodeList = getCityCodeList();//获取城市列表
        /*获取所有高速主干路名单*/
        ResultSet mainHighWaySet = HighwayCongestionDAO.getAllMainHighWay();
        HashSet<Pair<String, String>> mainHighwayMap = new HashSet<>();
        while(mainHighWaySet.next()){
            mainHighwayMap.add(
                    new Pair<>(mainHighWaySet.getString("highway_name"),
                            mainHighWaySet.getString("highway_code"))
            );
        }
        System.out.println(mainHighWaySet.toString());
        mainHighWaySet.getStatement().close();
        mainHighWaySet.close();

            File file = new File("./highwayLocation.sql");
            FileOutputStream fos = null;
            if(!file.exists()){
                file.createNewFile();//如果文件不存在，就创建该文件
                fos = new FileOutputStream(file);//首次写入获取
            }else{
                //如果文件已存在，那么就在文件末尾追加写入
                fos = new FileOutputStream(file,true);//这里构造方法多了一个参数true,表示在文件末尾追加写入
            }

            OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");//指定以UTF-8格式写入文件

        final String HIGHWAY_CONGESTION_LOCATION_LEFT = "https://jiaotong.baidu.com/trafficindex/city/roadcurve?cityCode=";
        //"https://jiaotong.baidu.com/trafficindex/city/roadcurve?cityCode=131&id=%E4%BA%AC%E8%97%8F%E9%AB%98%E9%80%9F-2";
        boolean isGoon = false;
        for(Pair<String, String> highwayName: mainHighwayMap) {
            for (int j = 0; j <= 0; j++) {
                for(int i = 0; i < cityCodeList.size(); i++){
//                    if(highwayName.getA().equals("兰海高速") && j == 5 && i == 62) isGoon = true;
//                    if(isGoon == false) continue;
                    Thread.sleep(120);
                    String roadSegID = "";
                    if (j >= 0) roadSegID = roadSegID + "-" + String.valueOf(j);
                    String url = HIGHWAY_CONGESTION_LOCATION_LEFT + cityCodeList.get(i).getB() + "&id=" + highwayName.getA() + roadSegID;
                    System.out.println(url + "\n");
                    System.out.println(highwayName.getA() + " " + roadSegID + " " + String.valueOf(i));
                    JSONObject jo = new JSONObject();

                    try {
                        jo = JSON.parseObject(WebSpiderUtil.getJsonFromURL(url));
                        jo.getJSONObject("data");
                    } catch (Exception e) {
                        continue;
                    }
                    String linkString = jo.getJSONObject("data").getString("links");
                    String[] highwaySegmentArray = linkString.split("\\|");
                    JSONArray ja = jo.getJSONObject("data").getJSONArray("location");
                    try {
                        ja.size();
                    } catch (NullPointerException e) {
                        continue;
                    }
                    JSONArray curve_ja = jo.getJSONObject("data").getJSONArray("curve");
                    //String geom = "MULTILINESTRING(";
                    for (int k = 0; k < ja.size(); k++) {
                        System.out.println();
                        String highwayPointString = ja.get(k).toString();
                        String[] longitudeAndLatitude = highwayPointString.split(",");
                        String lineGeom = "LINESTRING(" + longitudeAndLatitude[0] + " " + longitudeAndLatitude[1];
                        boolean isLongitude = true;
                        for (int p = 2; p < longitudeAndLatitude.length; p++) {
                            if (isLongitude) lineGeom = lineGeom + "," + longitudeAndLatitude[p];
                            else lineGeom = lineGeom + " " + longitudeAndLatitude[p];
                            isLongitude = !isLongitude;
                        }
                        lineGeom = lineGeom + ")";
                        /*insert into main_highway_cn ( highway_name, highway_code, seg_name, seg_id, geom )values('京沪高速', 'G2', '京沪高速-1', '16166649300:1', ST_GeomFromText('LINESTRING(116.464274 39.866145,116.463489 39.866775,116.463427 39.866829)', 4326));*/
//                        String sql = "insert into main_highway_cn ( highway_name, highway_code, seg_name, seg_id, geom )" +
//                                "values('" + highwayName.getA() + "', '" + highwayName.getB() + "', '" +
//                                highwayName.getA() + roadSegID + "', '" + highwaySegmentArray[k] +
//                                "', ST_GeomFromText('" + lineGeom + "', 4326));\n";
//                        HighwayCongestionDAO.insertHighwayLocation(highwayName.getA(), highwayName.getB(),
//                                highwayName.getA() + roadSegID, highwaySegmentArray[k],
//                                "ST_GeomFromText('" + lineGeom + "', 4326)");
                        //System.out.println(sql);
                        try {
                            JSONObject fuck = curve_ja.getJSONObject(curve_ja.size() - 1);
                            Double speed = fuck.getDouble("speed");
                            Double index = fuck.getDouble("congestIndex");
                            String update_time = DateUtil.getCurrentTime().substring(0, 10) + " " + fuck.getString("datatime");

                            String s = HighwayCongestionDAO.insertHighwayLocation(highwayName.getA(), highwayName.getB(),
                                    highwayName.getA() + roadSegID, highwaySegmentArray[k],
                                    "ST_GeomFromText('" + lineGeom + "', 4326)", update_time, speed, index);
                            System.out.println(s);
                            osw.write(s);
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }

                    }
                }
            }
        }
        osw.close();
    }
    public static void updateHighwayCongestionMap() throws IOException, SQLException, InterruptedException {
        List<Pair<String, String>> cityCodeList = getCityCodeList();//获取城市列表
        /*获取所有高速主干路名单*/
        ResultSet mainHighWaySet = HighwayCongestionDAO.getAllHighwaySegName();
        HashSet<Pair<String, String>> mainHighwayMap = new HashSet<>();
        while(mainHighWaySet.next()){
            mainHighwayMap.add(
                    new Pair<>(mainHighWaySet.getString("seg_name"),
                            mainHighWaySet.getString("city_code")
                    ));
        }
        System.out.println(mainHighWaySet.toString());
        mainHighWaySet.getStatement().close();
        mainHighWaySet.close();

        File file = new File("./highwayCongestUpdate.sql");
        FileOutputStream fos = null;
        if(!file.exists()){
            file.createNewFile();//如果文件不存在，就创建该文件
            fos = new FileOutputStream(file);//首次写入获取
        }else{
            //如果文件已存在，那么就在文件末尾追加写入
            fos = new FileOutputStream(file,true);//这里构造方法多了一个参数true,表示在文件末尾追加写入
        }

        OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");//指定以UTF-8格式写入文件

        final String HIGHWAY_CONGESTION_LOCATION_LEFT = "https://jiaotong.baidu.com/trafficindex/city/roadcurve?cityCode=";
        //"https://jiaotong.baidu.com/trafficindex/city/roadcurve?cityCode=131&id=%E4%BA%AC%E8%97%8F%E9%AB%98%E9%80%9F-2";
        boolean isGoon = false;
        for(Pair<String, String> highwayName: mainHighwayMap) {

                    //if(highwayName.getA().equals("京昆高速") && j == 3 && i == 37) isGoon = true;
                    //if(isGoon == false) continue;
                    Thread.sleep(120);
                    String url = HIGHWAY_CONGESTION_LOCATION_LEFT + highwayName.getB() + "&id=" + highwayName.getA();
                    System.out.println(url + "\n");
                    System.out.println(highwayName.getA() + " " + highwayName.getB());
                    JSONObject jo = new JSONObject();

                    try {
                        jo = JSON.parseObject(WebSpiderUtil.getJsonFromURL(url));
                        jo.getJSONObject("data");
                    } catch (Exception e) {
                        continue;
                    }
                    String linkString = jo.getJSONObject("data").getString("links");
                    String[] highwaySegmentArray = linkString.split("\\|");
                    JSONArray curve_ja = jo.getJSONObject("data").getJSONArray("curve");
                    for (int k = 0; k < highwaySegmentArray.length; k++) {
                        try {
                            JSONObject fuck = curve_ja.getJSONObject(curve_ja.size() - 1);
                            //Double speed = fuck.getDouble("speed");
                            Double index = fuck.getDouble("congestIndex");
                            String update_time = DateUtil.getCurrentTime().substring(0, 10) + " " + fuck.getString("datatime");
                            String s = HighwayCongestionDAO.updateHighwayCongestionMap(highwaySegmentArray[k], update_time, index, highwayName.getB());
                            System.out.println(s);
                            osw.write(s);
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }

                    }
                }
        osw.close();
    }
    public static String getHighwayCongestionMap(double ignoreValue) throws SQLException, ParseException {
        /**
         * @name = LX
         * @methodname = getHighwayCongestionMap
         * @description = 获取拥挤公路拥挤度及位置
         * @date = 2019/12/3
         */
        ResultSet resultSet = HighwayCongestionDAO.getHighwayCongestionMap(ignoreValue);
        JSONObject bigJo = new JSONObject();
        JSONArray ja = new JSONArray();
        String update_time = "2000-00-00 00:00:00";
        while(resultSet.next()){
            if(DateUtil.dateStringCompare(resultSet.getString("update_time"), update_time) == 1){
                update_time = resultSet.getString("update_time");
            }
            JSONObject jo = JSON.parseObject(JsonArrayToGeoJsonUtil.wkbToJson(resultSet.getString("geom")));
            jo.put("congestValue", resultSet.getDouble("congest"));
            ja.add(jo);
        }
        bigJo.put("update_time", update_time);
        bigJo.put("data", ja);
        return bigJo.toString();
    }

    public static String getAllHighwayLocationFromDatabase() throws SQLException {
        /**
         * @name = LX
         * @methodname = getAllHighwayLocationFromDatabase
         * @description = 多线程获取所有公路位置
         * @date = 2019/12/2
         */
        JSONArray ja = new JSONArray();

        ResultSet resultSet = HighwayCongestionDAO.getHighwayPoint();
        while(resultSet.next()){
            JSONObject jo = new JSONObject();
            jo.put("type", "Feature");
            JSONObject smallJo = new JSONObject();
            smallJo.put("type", "LineString");
            JSONArray pt = new JSONArray();
            JSONArray pt1 = new JSONArray();
            JSONArray pt2 = new JSONArray();

            Double x1 = resultSet.getDouble("x1");
            Double x2 = resultSet.getDouble("x2");
            Double y1 = resultSet.getDouble("y1");
            Double y2 = resultSet.getDouble("y2");

            pt1.add(x1);
            pt1.add(y1);
            pt2.add(x2);
            pt2.add(y2);
            pt.add(pt1);
            pt.add(pt2);
            smallJo.put("coordinates", pt);
            jo.put("geometry", smallJo);
            ja.add(jo);
        }
        return ja.toString();
        //return HighwayThread.jsonArray.toString();
    }
    public static String getHighwayCongestionFromWebSaveToDatabase() throws ParseException, SQLException {
        /**
         * @name = LX
         * @methodname = getHighwayCongestionFromWebSaveToDatabase
         * @description = 爬取所有城市拥挤度靠前的路，存到数据库里
         * @date = 2019/10/19
         */
        String highwayCongestionSQLString = new String("-- 公路拥挤度\n");
        int insertNum = 0;
        List<Pair<String, String>> cityCodeList = getCityCodeList();//获取城市列表
        /*获取所有高速主干路名单*/
        ResultSet mainHighWaySet = HighwayCongestionDAO.getAllMainHighWay();
        TreeMap<String, Boolean> mainHighwayMap = new TreeMap<>();
        while(mainHighWaySet.next()){
            mainHighwayMap.put(mainHighWaySet.getString("highway_name"), true);
        }
        mainHighWaySet.getStatement().close();
        mainHighWaySet.close();

        for(int i = 0; i < cityCodeList.size(); i++){
            //访问每个城市对应的URL，读取json
            String highWayCongestionJsonString = WebSpiderUtil.getJsonFromURL(getCityHighwayURL(cityCodeList.get(i).getB()));
            highWayCongestionJsonString = highWayCongestionJsonString.substring(28, highWayCongestionJsonString.length() - 1);//提取JSON部分
            //System.out.println(highWayCongestionJsonString);
            JSONObject cityCodeJsonObject = JSON.parseObject(highWayCongestionJsonString);
            /*定位list*/
            JSONObject data = cityCodeJsonObject.getJSONObject("data");
            JSONArray list = data.getJSONArray("list");
            for(int j = 0; j < list.size(); j++) {
                JSONObject cityElement = list.getJSONObject(j);
                /*json转实体*/
                if(!mainHighwayMap.containsKey(cityElement.getString("roadname"))) continue;//如果当前遍历到的是高速主干路再处理，否则直接看下一个

                HighwayCongestionModel highwayCongestionModel = new HighwayCongestionModel(cityElement);
                ResultSet resultSet = HighwayCongestionDAO.getNearestHighwaySegment(highwayCongestionModel.getRoad_name(), highwayCongestionModel.getLongitude(), highwayCongestionModel.getLatitude());//获取最近高速公路段的地理位置信息
                resultSet.next();
                highwayCongestionModel.setGeom(resultSet.getString("geom"));
                //highwayCongestionModel.setGeom(null);
                highwayCongestionModel.setCity_name(cityCodeList.get(i).getA());
                resultSet.getStatement().close();
                resultSet.close();
                //System.out.println(highwayCongestionModel.toString());
                //System.out.println(cityCodeList.get(i).getA() + highwayCongestionModel.getRoad_name());
                highwayCongestionSQLString = highwayCongestionSQLString + HighwayCongestionDAO.insertHighwayCongestion(highwayCongestionModel, false) + "\n";
            }
        }
        return highwayCongestionSQLString;
    }
    public static List<Pair<String, String>> getCityCodeList(){
        /**
         * @name = LX
         * @methodname = getSeaAreaUrlList
         * @description = 使用爬虫从百度地图智慧交通上爬取各个城市的CityCode
         * @date = 2019/10/19
         */
        List<Pair<String, String>> cityCodeList = new ArrayList<>();
        String cityCodeJsonString = WebSpiderUtil.getJsonFromURL("https://jiaotong.baidu.com/trafficindex/city/list?callback=jsonp_1571467628653_425118");
        cityCodeJsonString = cityCodeJsonString.substring(27, cityCodeJsonString.length() - 1);//提取JSON部分
        JSONObject cityCodeJsonObject = JSON.parseObject(cityCodeJsonString);
        JSONObject data = cityCodeJsonObject.getJSONObject("data");
        JSONArray list = data.getJSONArray("list");
        for(int i = 0; i < list.size(); i++) {
            JSONObject cityElement = list.getJSONObject(i);
            cityCodeList.add(new Pair<>(cityElement.getString("cityname"),cityElement.getString("citycode")));
        }
        return cityCodeList;
    }

    public static String getHighwayCongestPointFromWeb(){
        /**
         * @name = LX
         * @methodname = getHighwayCongestPointFromWeb
         * @description = 使用爬虫从百度地图智慧交通上爬取拥挤点
         * @date = 2019/12/04
         */
        final String HIGHWAY_CONGEST_POINT_URL = "http://jiaotong.baidu.com/trafficindex/dashboard/highwayroadrank?provinceCode=0&from=2";
        JSONObject jo = JSON.parseObject(WebSpiderUtil.getJsonFromURL(HIGHWAY_CONGEST_POINT_URL));
        JSONArray ja = jo.getJSONObject("data").getJSONArray("list");
        List<HighwayCongestPointModel> highwayCongestPointModelList = new ArrayList<>();
        BigDecimal maxR = new BigDecimal("0");
        JsonObject collection = new JsonObject();
        for(int i = 0; i < ja.size(); i++){//遍历拥挤点数组
            JSONObject highwayPoint = ja.getJSONObject(i);
            String updateTime = highwayPoint.getString("data_time");
            updateTime = updateTime.substring(0, 4) + "-" + updateTime.substring(4, 6) + "-" + updateTime.substring(6, 8) +
            " " + updateTime.substring(8, 10) + ":" + updateTime.substring(10, 12);
            String highwayLocation = highwayPoint.getString("location");
            String location[] = highwayLocation.split(",");
            //BigDecimal bdSpeed = new BigDecimal(highwayPoint.getString("speed"));
            //System.out.println(bdSpeed);
//            bdSpeed = bdSpeed.add(new BigDecimal("-90"));
//            bdSpeed = bdSpeed.divide(new BigDecimal("90"),2, RoundingMode.HALF_UP);
//            bdSpeed = bdSpeed.max(new BigDecimal("0"));
            BigDecimal congestLength = new BigDecimal(highwayPoint.getString("congest_length"));
            //highwayPoint.getString("semantic");
            //highwayPoint.getString("roadname");
            Double congestValue = Math.max(0.0, 90.0 - highwayPoint.getDouble("speed")) / 90.0;
            Point2D truePos = CorrdinateUtil.bd_decrypt(Double.parseDouble(location[1]), Double.parseDouble(location[0]));
            System.out.println(updateTime);
            System.out.println(congestLength);
            System.out.println(congestValue);
            maxR = maxR.max(congestLength);
            highwayCongestPointModelList.add(new HighwayCongestPointModel(new BigDecimal(congestValue * 100), String.valueOf(truePos.getX()), String.valueOf(truePos.getY()), congestLength));
            if(!collection.has("update_time")) collection.addProperty("update_time", updateTime);
        }
        // 转成json
        JsonArray pointArray = new JsonArray();
        for(HighwayCongestPointModel congestPoint: highwayCongestPointModelList){
            BigDecimal showR = new BigDecimal(congestPoint.getRadius().toString());
            showR = showR.divide(maxR,2, RoundingMode.HALF_UP);
            showR = showR.multiply(new BigDecimal("70"));
            showR = showR.add(new BigDecimal("30"));
            congestPoint.setRadius(showR);

            pointArray.add(congestPoint.toJsonObject());
            //System.out.println(congestPoint.toString());
        }
        collection.add("data", pointArray);
        return collection.toString();
    }
//    public static String  tempCongestionPoint(){
//        JSONObject jo = JSON.parseObject("{\"update_time\":\"2019-12-04 15:40\",\"data\":[{\"lon\":\"113.89253990099697\",\"la\":\"22.934051822352707\",\"congest_value\":63.28,\"radius\":100.00},{\"lon\":\"113.98221280256747\",\"la\":\"22.904037425075366\",\"congest_value\":65.86,\"radius\":97.90},{\"lon\":\"120.96599033465266\",\"la\":\"31.71919375887839\",\"congest_value\":87.02,\"radius\":90.90},{\"lon\":\"113.30346336788871\",\"la\":\"23.299719024590612\",\"congest_value\":64.53,\"radius\":75.50},{\"lon\":\"120.8736222956816\",\"la\":\"31.690918635823444\",\"congest_value\":63.86,\"radius\":72.70},{\"lon\":\"114.13523878501483\",\"la\":\"23.16027992649704\",\"congest_value\":46.91,\"radius\":62.20},{\"lon\":\"113.26168651025282\",\"la\":\"23.229886910400317\",\"congest_value\":62.92,\"radius\":57.30},{\"lon\":\"120.42296094573817\",\"la\":\"31.529641412361585\",\"congest_value\":64.39,\"radius\":53.10},{\"lon\":\"119.38792097542061\",\"la\":\"33.22138993278015\",\"congest_value\":27.89,\"radius\":53.10},{\"lon\":\"113.1311269215999\",\"la\":\"23.106864291266714\",\"congest_value\":71.58,\"radius\":53.10},{\"lon\":\"116.7501060070254\",\"la\":\"38.309012678740444\",\"congest_value\":68.10,\"radius\":51.00},{\"lon\":\"111.69727910808943\",\"la\":\"39.76097700627636\",\"congest_value\":49.12,\"radius\":51.00},{\"lon\":\"110.33075661177863\",\"la\":\"38.187017517284765\",\"congest_value\":51.70,\"radius\":49.60},{\"lon\":\"120.31617232293553\",\"la\":\"31.823184578573304\",\"congest_value\":46.09,\"radius\":49.60},{\"lon\":\"114.50365700066614\",\"la\":\"22.825725922949403\",\"congest_value\":76.34,\"radius\":48.90},{\"lon\":\"106.57788553886873\",\"la\":\"26.617066969765354\",\"congest_value\":73.30,\"radius\":47.50},{\"lon\":\"120.66674262003401\",\"la\":\"30.82549154815016\",\"congest_value\":51.10,\"radius\":47.50},{\"lon\":\"114.81966615424547\",\"la\":\"23.938829458997805\",\"congest_value\":43.41,\"radius\":47.50},{\"lon\":\"121.23694023938181\",\"la\":\"28.804722792252072\",\"congest_value\":45.78,\"radius\":46.80},{\"lon\":\"116.4093950316034\",\"la\":\"35.93711105167384\",\"congest_value\":60.02,\"radius\":46.10},{\"lon\":\"113.04829169982824\",\"la\":\"22.998723218246518\",\"congest_value\":75.36,\"radius\":46.10},{\"lon\":\"111.05630108171901\",\"la\":\"33.44296962978541\",\"congest_value\":95.46,\"radius\":45.40},{\"lon\":\"113.29914671571342\",\"la\":\"22.939888737474387\",\"congest_value\":54.24,\"radius\":45.40},{\"lon\":\"118.27732308578318\",\"la\":\"24.677986042637606\",\"congest_value\":55.68,\"radius\":45.40},{\"lon\":\"104.53451014408529\",\"la\":\"25.777197014285882\",\"congest_value\":17.96,\"radius\":45.40},{\"lon\":\"113.44432900206007\",\"la\":\"36.532164080416095\",\"congest_value\":59.52,\"radius\":45.40},{\"lon\":\"112.90437959852736\",\"la\":\"22.992031461965716\",\"congest_value\":27.67,\"radius\":45.40},{\"lon\":\"113.9089198958966\",\"la\":\"22.655717739978723\",\"congest_value\":34.20,\"radius\":44.70},{\"lon\":\"120.2443383899454\",\"la\":\"32.01174717912928\",\"congest_value\":41.70,\"radius\":44.70},{\"lon\":\"113.24732619035434\",\"la\":\"23.165786205380684\",\"congest_value\":69.10,\"radius\":44.00},{\"lon\":\"112.19908817297193\",\"la\":\"39.65319195636561\",\"congest_value\":35.81,\"radius\":44.00},{\"lon\":\"103.98704034565336\",\"la\":\"30.521886681369406\",\"congest_value\":29.81,\"radius\":44.00},{\"lon\":\"114.67008942519438\",\"la\":\"23.678113645697085\",\"congest_value\":41.38,\"radius\":43.30},{\"lon\":\"117.35332135846853\",\"la\":\"38.42023345348457\",\"congest_value\":14.04,\"radius\":42.60},{\"lon\":\"115.95375527445412\",\"la\":\"29.649593235350007\",\"congest_value\":71.22,\"radius\":42.60},{\"lon\":\"119.49709001584478\",\"la\":\"32.84383176860772\",\"congest_value\":7.99,\"radius\":41.90},{\"lon\":\"112.1993080297031\",\"la\":\"39.656939055732316\",\"congest_value\":19.00,\"radius\":41.90},{\"lon\":\"117.34342202859683\",\"la\":\"38.42971712180354\",\"congest_value\":13.12,\"radius\":41.90},{\"lon\":\"118.27351575564948\",\"la\":\"24.677857817954898\",\"congest_value\":36.11,\"radius\":41.90},{\"lon\":\"102.79004497805383\",\"la\":\"24.953300030509002\",\"congest_value\":84.89,\"radius\":41.20},{\"lon\":\"113.91242510329526\",\"la\":\"22.65571768726206\",\"congest_value\":44.37,\"radius\":41.20},{\"lon\":\"113.2338064636068\",\"la\":\"23.315116454021076\",\"congest_value\":43.16,\"radius\":41.20},{\"lon\":\"118.07832826147755\",\"la\":\"35.36078360378289\",\"congest_value\":44.62,\"radius\":41.20},{\"lon\":\"120.43042181201808\",\"la\":\"31.524072660000627\",\"congest_value\":48.20,\"radius\":40.50},{\"lon\":\"120.8841580680493\",\"la\":\"40.83441776399229\",\"congest_value\":22.62,\"radius\":40.50},{\"lon\":\"102.80637543568324\",\"la\":\"24.81957161330371\",\"congest_value\":59.99,\"radius\":40.50},{\"lon\":\"117.96231650123953\",\"la\":\"39.40412466150767\",\"congest_value\":25.63,\"radius\":39.80},{\"lon\":\"114.30097596741486\",\"la\":\"38.17825387937898\",\"congest_value\":12.30,\"radius\":39.80},{\"lon\":\"115.76799361548589\",\"la\":\"31.89453271683149\",\"congest_value\":18.31,\"radius\":39.80},{\"lon\":\"120.36809148975209\",\"la\":\"30.312503520170125\",\"congest_value\":41.92,\"radius\":39.10},{\"lon\":\"110.90855970350707\",\"la\":\"37.42182131819755\",\"congest_value\":32.59,\"radius\":39.10},{\"lon\":\"121.37161356776762\",\"la\":\"41.10182488153832\",\"congest_value\":11.59,\"radius\":38.40},{\"lon\":\"113.03860971805103\",\"la\":\"27.9198228144054\",\"congest_value\":42.98,\"radius\":38.40},{\"lon\":\"115.9550046735999\",\"la\":\"40.36430863099118\",\"congest_value\":67.54,\"radius\":37.70},{\"lon\":\"121.75303913343532\",\"la\":\"31.19873023683388\",\"congest_value\":22.28,\"radius\":37.70},{\"lon\":\"113.43550501171424\",\"la\":\"36.530803335982306\",\"congest_value\":46.71,\"radius\":37.70},{\"lon\":\"107.8394954426582\",\"la\":\"35.21626870283211\",\"congest_value\":44.03,\"radius\":37.70},{\"lon\":\"114.09506318954749\",\"la\":\"37.97807525977044\",\"congest_value\":27.83,\"radius\":37.00},{\"lon\":\"112.34966446293961\",\"la\":\"31.33319126346946\",\"congest_value\":16.92,\"radius\":37.00},{\"lon\":\"106.35885054025958\",\"la\":\"32.8484743695253\",\"congest_value\":43.94,\"radius\":37.00},{\"lon\":\"125.0414169395936\",\"la\":\"45.560405661057715\",\"congest_value\":55.20,\"radius\":37.00},{\"lon\":\"113.02584247955679\",\"la\":\"23.127703517220464\",\"congest_value\":8.69,\"radius\":37.00},{\"lon\":\"98.91393495814205\",\"la\":\"36.76218025152051\",\"congest_value\":8.87,\"radius\":36.30},{\"lon\":\"108.31125107837188\",\"la\":\"22.89528405661727\",\"congest_value\":77.12,\"radius\":36.30},{\"lon\":\"102.81132319342899\",\"la\":\"36.335131088525706\",\"congest_value\":18.43,\"radius\":36.30},{\"lon\":\"121.21888087550647\",\"la\":\"31.3622545214441\",\"congest_value\":30.44,\"radius\":36.30},{\"lon\":\"121.14763421543464\",\"la\":\"31.286286924562642\",\"congest_value\":81.79,\"radius\":36.30},{\"lon\":\"114.05498329915889\",\"la\":\"22.64434441867944\",\"congest_value\":90.73,\"radius\":35.60},{\"lon\":\"112.10697895931905\",\"la\":\"32.22077593157032\",\"congest_value\":23.77,\"radius\":35.60},{\"lon\":\"102.53143039601494\",\"la\":\"24.352150214858348\",\"congest_value\":25.39,\"radius\":35.60},{\"lon\":\"112.13816623325651\",\"la\":\"30.024382346592727\",\"congest_value\":3.74,\"radius\":35.60},{\"lon\":\"113.04025341362794\",\"la\":\"27.530705115498673\",\"congest_value\":4.16,\"radius\":35.60},{\"lon\":\"109.07728260214365\",\"la\":\"34.3026637261344\",\"congest_value\":31.87,\"radius\":35.60},{\"lon\":\"114.66472500184292\",\"la\":\"30.42715124158461\",\"congest_value\":41.01,\"radius\":35.60},{\"lon\":\"99.07054690296431\",\"la\":\"24.98416267921873\",\"congest_value\":24.71,\"radius\":35.60},{\"lon\":\"109.92474622084414\",\"la\":\"21.551305216397196\",\"congest_value\":15.31,\"radius\":35.60},{\"lon\":\"108.9580446693765\",\"la\":\"34.18878271253863\",\"congest_value\":45.58,\"radius\":34.90},{\"lon\":\"113.03834855256204\",\"la\":\"27.922353810372673\",\"congest_value\":28.51,\"radius\":34.90},{\"lon\":\"120.14670405422933\",\"la\":\"36.06433396168748\",\"congest_value\":75.41,\"radius\":34.90},{\"lon\":\"113.37125340038173\",\"la\":\"23.27459088681823\",\"congest_value\":47.88,\"radius\":34.90},{\"lon\":\"117.04262957027741\",\"la\":\"39.7851059965272\",\"congest_value\":13.66,\"radius\":34.90},{\"lon\":\"106.89210097680667\",\"la\":\"29.68903189024465\",\"congest_value\":20.30,\"radius\":34.90},{\"lon\":\"116.42515991631882\",\"la\":\"23.611582329742667\",\"congest_value\":18.14,\"radius\":34.90},{\"lon\":\"120.0512644641903\",\"la\":\"36.00215144252578\",\"congest_value\":36.31,\"radius\":34.90},{\"lon\":\"121.02017389166419\",\"la\":\"31.3313226483102\",\"congest_value\":1.10,\"radius\":34.90},{\"lon\":\"116.74114913135821\",\"la\":\"40.0064976034242\",\"congest_value\":73.41,\"radius\":34.90},{\"lon\":\"110.69581514658204\",\"la\":\"35.61480041730485\",\"congest_value\":3.38,\"radius\":34.90},{\"lon\":\"118.04153558387755\",\"la\":\"28.537405209832556\",\"congest_value\":10.93,\"radius\":34.90},{\"lon\":\"120.85215290184276\",\"la\":\"31.58727204985066\",\"congest_value\":3.31,\"radius\":34.90},{\"lon\":\"120.76840941573404\",\"la\":\"31.36764820605494\",\"congest_value\":15.40,\"radius\":34.90},{\"lon\":\"111.62154939363597\",\"la\":\"24.366293327890975\",\"congest_value\":8.27,\"radius\":34.90},{\"lon\":\"108.44409512242714\",\"la\":\"27.942594031098494\",\"congest_value\":22.67,\"radius\":34.90},{\"lon\":\"105.94394200543334\",\"la\":\"26.221038017170915\",\"congest_value\":28.04,\"radius\":34.20},{\"lon\":\"126.5145863216804\",\"la\":\"45.84840650782351\",\"congest_value\":80.00,\"radius\":34.20},{\"lon\":\"121.12857535836832\",\"la\":\"31.5227061358412\",\"congest_value\":1.22,\"radius\":34.20},{\"lon\":\"104.73067211031942\",\"la\":\"35.13895800791614\",\"congest_value\":11.63,\"radius\":34.20},{\"lon\":\"121.18494182235487\",\"la\":\"31.409550675937147\",\"congest_value\":43.62,\"radius\":34.20},{\"lon\":\"104.20629199153713\",\"la\":\"30.811126563015186\",\"congest_value\":36.06,\"radius\":34.20},{\"lon\":\"104.27323880444067\",\"la\":\"28.536610255463565\",\"congest_value\":17.51,\"radius\":34.20},{\"lon\":\"113.67666093290865\",\"la\":\"22.912975260850946\",\"congest_value\":16.79,\"radius\":34.20}]}\n");
//        return jo.toString();
//    }

}
